package com.liwei.lwmail.order.web;

import com.liwei.lwmail.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.UUID;

@Controller
public class HelloController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @ResponseBody
    @GetMapping("/testCreateOrder")
    public String createOrder(){
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn(UUID.randomUUID().toString());
        orderEntity.setCreateTime(new Date());
        rabbitTemplate.convertAndSend("order.event.exchange","order.create.order",orderEntity);
        System.out.println("创建订单。。。");
        return "ok";
    }

    @GetMapping("/{page}.html")
    public String toPage(@PathVariable("page") String page){
        HashMap<String, String> stringStringHashMap = new HashMap<>();
        return page;
    }

}
